//
//  smuGraph.hpp
//  smu_test1
//
//  Created by jiayi on 16/9/26.
//
//

#ifndef smuGraph_hpp
#define smuGraph_hpp

struct smuNode;

class smuGraph
{
public:
    typedef function<void(smuNode*,int)> funcNode;
    typedef map< smuNode*, bool > visibleMap;
    
public:
    // save to vector
    void save( smuNode* root, vector<string>& result );
    
    // update nodes who rely on the given node recursively
    void updateBFS( smuNode* node, int param );
    
    // update relies of the given node
    void updateRelies( smuNode* node, int param, visibleMap& visible  );
    
    // add link between two nodes, circle return false
    bool addLink( smuNode* node, smuNode* rely );
    
    // set callback
    void setUpdateFinishedFunction( const funcNode& func ) { _f = func; }
    
protected:
    bool _circle( smuNode* node, smuNode* to );
    
protected:
    funcNode _f;
};

#endif /* smuGraph_hpp */
